#include <stdio.h>
#define COLS 4

int sum2d(const int arr[][COLS], int rows);
int sum(const int arr[], int n);

int main(void) {
    int t1, t2, t3;
    int *p1;
    int (*p2)[COLS];
    
    p1 = (int[2]) {10, 20};
    p2 = (int[2][COLS]) {{1, 2, 3, -9}, {4, 5, 6, -8}};

    t1 = sum(p1, 2);
    t2 = sum2d(p2, 2);
    t3 = sum((int[]) {4, 4, 4, 5, 5, 5}, 6);

    printf("t1 = %d\n", t1);
    printf("t2 = %d\n", t2);
    printf("t3 = %d\n", t3);

    return 0;
}

int sum2d(const int arr[][COLS], int rows) {
    int i, j;
    int t = 0;
    for (i = 0; i < rows; i++)
        for (j = 0; j < COLS; j++)
            t += arr[i][j];

    return t;
}

int sum(const int arr[], int n) {
    int i;
    int t = 0;
    for (i = 0; i < n; i++)
        t += arr[i];

    return t;
}
